package com.testmanager.testmananger.shuiyou.strCompare.respository;

import com.testmanager.testmananger.shuiyou.strCompare.domain.SyCompareResultEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface SyCompareResultRepository extends JpaRepository<SyCompareResultEntity,Long>, JpaSpecificationExecutor<SyCompareResultEntity>
        , QuerydslPredicateExecutor<SyCompareResultEntity> {


    SyCompareResultEntity findById(long id);

    List<SyCompareResultEntity>  findAllByCompareTaskidOrderByIdDesc(long taskId);

    @Query(value = "select t from SyCompareResultEntity t where t.createdDate = (select max(d.createdDate) from SyCompareResultEntity d where d.compareTaskid=:taskid) and t.compareTaskid=:taskid")
   // @Query(value = "select * from")
    SyCompareResultEntity findNearestResultBytaskid(@Param("taskid") long taskid);

}
